<div class="bjui-pageHeader">
    <div class="pull-right">
        <button class="btn-default" data-icon="plus" title="新增产品" data-toggle="tooltip" data-placement="left" onclick="createNavtab('{:U("Forms/pro", array('item'=>'1'))}', '新增商品', 'pro')" ></button>
        <button class="btn-default" data-icon="refresh" onclick="$.CurrentNavtab.navtab('refresh')"></button>
    </div>
    <form id="pagerForm" data-toggle="ajaxsearch" data-loadingmask="true" action="{:U('index')}" method="post">
        <input type="hidden" name="pageSize" value="{:I('param.pageSize')}" />
        <input type="hidden" name="pageCurrent" value="{:I('param.pageCurrent')}" />
        <input type="hidden" name="orderField" value="{:I('param.orderField')}" />
        <input type="hidden" name="orderDirection" value="{:I('param.orderDirection')}" />
        <div class="bjui-searchBar">
            <label>所有分类:</label>
            <select name="class_id" data-toggle="selectpicker">
                <option value="0">--请选择--</option>
                <volist name="res" id="vo">
                   <option value="{$vo.id}" <if condition="I('class_id') eq $vo['id']">selected</if>>{$vo.name}</option>
                </volist>
            </select>
            <label>品牌:</label>
            <select name="brandid" data-toggle="selectpicker">
                <option value="0">--请选择--</option>
                <volist name="brandlist" id="bo">
                <option value="{$bo.id}" <if condition="I('brandid') eq $bo['id']">selected</if>>{$bo.name}</option>
                </volist>
            </select>
            <label>状态:</label>
            <select name="status" data-toggle="selectpicker">
                <option value="">--请选择--</option>
                <option value="0" <if condition="I('status') eq '0'">selected</if>>上架</option>
                <option value="1" <if condition="I('status') eq '1'">selected</if>>下架</option>
            </select>
            <label>类型:</label>
            <select name="commend_id" data-toggle="selectpicker">
                <option value="1">--请选择--</option>
                <volist name="commend" id="co">
                  <option value="{$co.id}" <if condition="I('commend_id') eq $co['id']">selected</if>>{$co.name}</option>
                </volist>
            </select>
            <label>名称:</label>
            <input type="text" name="name" value="{:I('name')}" />
            <button type="submit" class="btn-default" data-icon="search">查询</button>
            <a class="btn btn-orange" href="javascript:;" data-toggle="reloadsearch" data-clear-query="true" data-icon="undo">清空查询 </a>
        </div>
    </form>
</div>
<div class="bjui-pageContent tableContent">
    <table class="table table-bordered table-hover table-striped table-top prolist" data-selected-multi="false" >
        <thead>
        <tr>
            <th width="40">NO.</th>
            <th>商品名称</th>
            <th>所属类型</th>
            <th>所属商家</th>
            <th>货号</th>
            <th>分类</th>
            <th width="120">价格</th>
            <th width="70">是否上架</th>
            <th width="70">权重</th>
            <!-- <th width="70">查看库存</th> -->
            <th width="140">操作</th>
        </tr>
        </thead>
        <tbody>
        <!--data-id === 商品ID,修改库存,权重时调用-->
        <volist name="list" id="vo">
        <tr data-id="{$vo.id}">
            <td>{$vo.id}</td>
            <td><a href="javascript:void(0)" target="_blank">{$vo.name}</a></td>
            <td>{$vo.commend_name}</td>
            <td>{$vo.shop_name}</td>
            <td>{$vo.goods_no}</td>
            <td>{:goods_class($vo['id'],",")}</td>
            <td>{:goods_price($vo['id'])}元</td>
            <if condition="$vo.status eq '0'">
            <td><a href="{:U('Forms/update_goods_status',array('id'=>$vo['id']))}" data-type="get" data-toggle="doajax" data-confirm-msg="确定要下架这个商品吗??">是</a></td>
            <else/>
            <td><a href="{:U('Forms/update_goods_status',array('id'=>$vo['id']))}" data-type="get" data-toggle="doajax" data-confirm-msg="确定要上架这个商品吗??">否</a></td>
            </if>
            <td class="prolist"><input type="text" value="{$vo.sort}" maxlength="3" style="width:40" data-type="sort"/></td>
            <!-- <td><button type="button" class="btn-green" onclick="createNavtab('{:U("Forms/pro_pro",array('id'=>$vo["id"]))}', '查看库存', 'pro_pro')">查看库存</button></td> -->
            <td>
                <!-- <a href="__APP__/Site/item/goodid/{$vo.id}_{$vo.product_id}" target="_blank" class="btn btn-blue">看</a> -->
                <button type="button" class="btn-green"  onclick="createNavtab('{:U("Forms/pro",array('id'=>$vo["id"]))}', '编辑商品', 'pro')">改</button>
                <a href="{:U('Forms/del_goods',array('id'=>$vo['id']))}" data-type="get" class="btn btn-red" data-toggle="doajax" data-confirm-msg="要删除这个商品??" >删</a>
            </td>
        </tr>
        </volist>
        </tbody>
    </table>
</div>
<script>
    $(function () {
        $('.prolist input[type=text]').keyup(function () {
            var v = $(this).val(),
                    type = $(this).attr('data-type'),
                    pid = $(this).parents('tr').attr('data-id');
           $(this).bjuiajax('doAjax', {
              url:'{:U("Forms/sort_goods")}',
               type:'post',
               data:{val: v, id : pid,type:type},
               loadingmask:false,
               callback:function (json) {
                   if (json[BJUI.keys.statusCode] != BJUI.keys.statusCode){
                        $(this).bjuiajax('ajaxDone', json);
                   }
                   return false;
               }
           });
        });
    });

</script>

<include file="Common/footer" ftype="page" />